#pragma once

#include "qmlgraphicsview.h"

class QmlGraphicsViewPreview : public QQuickItem
{
    Q_OBJECT
public:
    explicit QmlGraphicsViewPreview(QQuickItem* parent = nullptr);
    virtual ~QmlGraphicsViewPreview() = default;
    Q_DISABLE_COPY(QmlGraphicsViewPreview)

public:
    Q_PROPERTY(QmlGraphicsView* source READ getSource WRITE setSource NOTIFY sourceChanged FINAL)

    inline QmlGraphicsView* getSource() const noexcept
    {
        return m_source.data();
    }
    void setSource(QmlGraphicsView* source) noexcept;

protected:
    Q_INVOKABLE QRectF rectUnion(QRectF a, QRectF b) const;

signals:
    void sourceChanged();

    void visibleWindowChanged(QRectF visibleWindowRect, qreal navigableZoom);

private:
    QPointer<QmlGraphicsView> m_source;
};

QML_DECLARE_TYPE(QmlGraphicsViewPreview)
